<%@page import="java.text.DateFormat"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.List"%>
<%@ page contentType="text/html;charset=UTF-8" language="java"
    pageEncoding="utf-8"%>
<%@ page import="net.sf.ehcache.*"%>
<jsp:useBean id="cache" type="net.sf.ehcache.Cache" scope="application" />
<%
DateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
%>
<form>
    <h3>缓存列表</h3>
    <table border="1px" width="100%">
        <tr>
            <th>区域</th>
            <th>键</th>
            <th>内容</th>
            <th>创建时间</th>
            <th>最后访问时间</th>
            <th>过期时间</th>
            <th>命中次数</th>
            <th>存活时间(秒)</th>
            <th>空闲时间(秒)</th>
        </tr>
        <%
        List elements = cache.getKeys();
        List keys = cache.getKeys();
        for(Object key : elements){
        if(!keys.isEmpty()){
            Element ele = cache.get(key);
        %>
        <tr>
            <td><%=cache.getName()%></td>
            <td><%=key%></td>
            <td><%=ele.getValue()%></td>
            <td><%=sf.format(ele.getCreationTime())%></td>
            <td><%=sf.format(ele.getLastAccessTime())%></td>
            <td><%=sf.format(ele.getExpirationTime())%></td>
            <td><%=ele.getHitCount()%></td>
            <td><%=ele.getTimeToLive()%></td>
            <td><%=ele.getTimeToIdle()%></td>
        </tr>
        <%
        }
            }
        %>
    </table>
    <br>
    <h3>缓存总统计</h3>
    <%
    Statistics stat = cache.getStatistics();
    %>
    <table border="1px" width="80%">
        <tr>
            <th>总数量</th>
            <th>内存数量</th>
            <th>磁盘数量</th>
            <th>命中次数</th>
            <th>内存命中</th>
            <th>磁盘命中</th>
        </tr>
        <tr>
            <td><%=cache.getSize()%></td>
            <td><%=cache.getMemoryStoreSize()%></td>
            <td><%=cache.getDiskStoreSize()%></td>
            <td><%=stat.getCacheHits()%></td>
            <td><%=stat.getInMemoryHits()%></td>
            <td><%=stat.getOnDiskHits()%></td>
        </tr>
    </table>
</form>
<p>
    <a href="index.jsp">Back to Index</a>
</p>